#region License Revision: 0 Last Revised: 6/18/2008 11:00 AM
/******************************************************************************
Copyright (c) Microsoft Corporation.  All rights reserved.


This file is licensed under the Microsoft Public License (Ms-PL). A copy of the Ms-PL should accompany this file. 
If it does not, you can obtain a copy from: 

http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx
******************************************************************************/
#endregion // License
using System;
using System.Windows.Browser;
using System.Diagnostics;
using ScriptInterop;
using System.Windows.Input;
using System.Windows;

namespace VIEWS
{
    /// <summary>
    /// Provides data for Virtual Earth map events.
    /// </summary>
    public class VEMapEventArgs : EventArgs
    {
        #region Member Variables
        private ScriptObject scriptObject;
        #endregion // Member Variables

        #region Constructors
        /// <summary>
        /// Initializes a new <see cref="VEMapEventArgs"/> instance from the underlying script instance.
        /// </summary>
        /// <param naEvent="scriptObject">
        /// The underlying script instance.
        /// </param>
        public VEMapEventArgs(ScriptObject scriptObject)
        {
            if (scriptObject == null) throw new ArgumentNullException("scriptObject");
            this.scriptObject = scriptObject;
        }
        #endregion // Constructors

        #region Public Properties
        /// <summary> A String object containing the error message, if any. </summary>
        public string Error
        {
            get { return scriptObject.GetProperty<string>("error"); }
        }

        /// <summary> The current map zoom level. </summary>
        public int ZoomLevel
        {
            get { return scriptObject.GetProperty<int>("zoomLevel"); }
        }

        /// <summary> The current map style as a String. Valid String results are a, r, h, and o. </summary>
        public string MapStyle
        {
            get { return scriptObject.GetProperty<string>("mapStyle"); }
        }

        /// <summary> If the map style is set to bird's eye (oblique), the unique identifier of the current bird's eye scene. </summary>
        public int BirdseyeSceneId
        {
            get { return scriptObject.GetProperty<int>("birdseyeSceneID"); }
        }

        /// <summary> If the map style is set to bird's eye (oblique), the orientation of the current bird's eye scene. </summary>
        public VEOrientation BirdseyeSceneOrientation
        {
            get { return ScriptEnumConverter.ToOrientation(scriptObject.GetProperty<string>("birdseyeSceneOrientation")); }
        }

        /// <summary> A boolean representing whether the left mouse button has been clicked. </summary>
        public bool LeftMouseButton
        {
            get { return scriptObject.GetProperty<bool>("leftMouseButton"); }
        }

        /// <summary> A boolean representing whether the right mouse button has been clicked. </summary>
        public bool RightMouseButton
        {
            get { return scriptObject.GetProperty<bool>("rightMouseButton"); }
        }

        /// <summary> A boolean representing whether the middle mouse button (or mouse wheel) has been clicked. </summary>
        public bool MiddleMouseButton
        {
            get { return scriptObject.GetProperty<bool>("middleMouseButton"); }
        }

        /// <summary> The number of units that the mouse wheel has changed. Note:  This is not supported in 3D mode, and the value returned in Firefox 1.5 and 2.0 is incorrect.  </summary>
        public int MouseWheelChange
        {
            get { return scriptObject.GetProperty<int>("mouseWheelChange"); }
        }

        /// <summary> The x coordinate of the mouse cursor relative to the browser window. </summary>
        public int ClientX
        {
            get { return scriptObject.GetProperty<int>("clientX"); }
        }

        /// <summary> The y coordinate of the mouse cursor relative to the browser window. </summary>
        public int ClientY
        {
            get { return scriptObject.GetProperty<int>("clientY"); }
        }

        /// <summary> The x coordinate of the mouse cursor relative to the screen. Note:  This is not supported in 3D mode.  </summary>
        public int ScreenX
        {
            get { return scriptObject.GetProperty<int>("screenX"); }
        }

        /// <summary> The y coordinate of the mouse cursor relative to the screen. Note: This is not supported in 3D mode. </summary>
        public int ScreenY
        {
            get { return scriptObject.GetProperty<int>("screenY"); }
        }

        /// <summary> The x coordinate of the map relative to the screen. Note:  This is not supported in 3D mode. </summary>
        public int MapX
        {
            get { return scriptObject.GetProperty<int>("mapX"); }
        }


        /// <summary> The y coordinate of the map relative to the screen. Note:  This is not supported in 3D mode. </summary>
        public int MapY
        {
            get { return scriptObject.GetProperty<int>("mapY"); }
        }

        /// <summary> The latlong coordinates of the clicked location. This only works in 3D mode. For 2D, you can convert mapX and mapY to a latlong using the VEMap.PixelToLatLong Method method. </summary>
        public VELatLong LatLong
        {
            get { ScriptObject so = scriptObject.GetProperty<ScriptObject>("latLong"); return new VELatLong(so); }
        }

        /// <summary> The key code of the key that has been pressed. Note:  This is not supported in 3D mode. </summary>
        public int KeyCode
        {
            get { return scriptObject.GetProperty<int>("keyCode"); }
        }

        /// <summary> A boolean representing whether the ALT key was held when the key was pressed. Note: This is not supported in 3D mode. </summary>
        public bool AltKey
        {
            get { return scriptObject.GetProperty<bool>("altKey"); }
        }

        /// <summary> A boolean representing whether the CTRL key was held when the key was pressed. Note: This is not supported in 3D mode. </summary>
        public bool CtrlKey
        {
            get { return scriptObject.GetProperty<bool>("ctrlKey"); }
        }

        /// <summary> A boolean representing whether the shift key was held when the key was pressed. Note: This is not supported in 3D mode.  </summary>
        public bool ShiftKey
        {
            get { return scriptObject.GetProperty<bool>("shiftKey"); }
        }

        /// <summary> A string representing the type of event that occurred. </summary>
        public string EventName
        {
            get { return scriptObject.GetProperty<string>("eventName"); }
        }

        /// <summary> The ID of the object associated with the event, usually a VEShape Class object or the base map.  </summary>
        public string ElementId
        {
            get { return scriptObject.GetProperty<string>("elementID"); }
        }

        /// <summary>
        /// Gets or sets a value that indicates if the event has been handled.
        /// </summary>
        /// <value>
        /// <c>true</c> if the event has been handled by the application; otherwise <c>false</c>.
        /// </value>
        /// <remarks>
        /// Setting this member to <c>true</c> during a mouse operation can cause panning and 
        /// zooming to stop functioning.
        /// </remarks>
        public bool Handled { get; set; }

        #endregion // Public Properties
    }
}
